<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AdminRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|unique:admins,username,'.$this->admin.'|max:100',
            'password' => 'nullable|string',
            'password2'=> 'required_with:password|same:password',
            
            
            
        ];
    }

    public function messages()
    {
        return [
            'truename.required' => '姓名 不能为空',
            'password2.required' => '密码确认 不能为空',
            'password2.same' => '两次输入的密码不一致',  
            'role_id.required' => '请选择角色',          
        ];
    }

    public function pure()
    {
        return  array_except($this->all(), ['_token','_method','password2']);
    }
}
